
using System;
using System.IO;
using Mono.Addins;
using MonoDevelop.Core.Gui;
using MonoDevelop.Core;
using MonoDevelop.Projects;
using MonoDevelop.Ide.Gui;

namespace MonoDevelop.XamlDesigner
{


	public class FileExtentionChecker: ConditionType
	{

		public FileExtentionChecker ()
		{
            	IdeApp.Workbench.ActiveDocumentChanged += delegate {this.NotifyChanged ();};
		}
        
        public override bool Evaluate (NodeElement conditionNode)
		{
            string val = conditionNode.GetAttribute ("extension");
			if (val.Length > 0) {

				string ext = Path.GetExtension (IdeApp.Workbench.ActiveDocument.FileName);
                
				foreach (string requiredExtension in val.Split (','))
					if (ext == "." + requiredExtension)
						return true;
			}
			return false;

        }
	}
}
